// 公用接口api asdfasdf
import { fetch, oss } from '@/utils/fetch.js';

export const ERROR_CODE = {
  REFRESH_LIST: 500001001, // 前三位500表示服务器错误，中间001表示前端拿到这个错误需要做进一步操作，最后001表示前端拿到之后需要刷新页面
};

// get请求示例
export function getdata(params) {
  return fetch({
    url: '/questionliburl',
    method: 'GET',
    data: params,
  });
}
//学管 保存更新
export function teacherTutorsaveOrUpdate(params) {
  return fetch({
    url: '/questionlib/teacherTutor/saveOrUpdate',
    method: 'POST',
    data: params,
  });
}
//学管 列表
export function queryTutorList(params) {
  return fetch({
    url: '/usercenter/operation/tutor/queryTutorList',
    method: 'POST',
    data: params,
  });
}
//学管 详情
export function getInfoByTutor(params) {
  return fetch({
    url: '/usercenter/operation/tutor/getInfoByTutor',
    method: 'POST',
    data: params,
  });
}

//学管更新 状态
export function updateById(params) {
  return fetch({
    url: '/questionlib/teacherTutor/updateById',
    method: 'POST',
    data: params,
  });
}

//学校报课  新增
export function enrollmentPlan(params) {
  return fetch({
    url: '/usercenter/operation/school/enrollmentPlan',
    method: 'POST',
    data: params,
  });
}

//学校报课  列表
export function enrollmentList(params) {
  return fetch({
    url: '/usercenter/operation/school/enrollmentList',
    method: 'POST',
    data: params,
  });
}
//学校报课  编辑
export function editEnrollmentPlan(params) {
  return fetch({
    url: '/usercenter/operation/school/editEnrollmentPlan',
    method: 'POST',
    data: params,
  });
}

//学校报课  详情
export function queryEnrollmentDetail(params) {
  return fetch({
    url: '/usercenter/operation/enrollment/queryEnrollmentDetail',
    method: 'POST',
    data: params,
  });
}

//学校报课  包含课程
export function getCourseByPlanId(params) {
  return fetch({
    url: '/usercenter/operation/school/getCourseByPlanId',
    method: 'POST',
    data: params,
  });
}
//学校报课  开关
export function closeOrOpenPlan(params) {
  return fetch({
    url: '/usercenter/operation/school/closeOrOpenPlan',
    method: 'POST',
    data: params,
  });
}

// 登录
export function login(params) {
  return fetch({
    url: '/usercenter/sys/login',
    method: 'POST',
    data: params,
  });
}
//获取用户信息
export function getUserInfo(params) {
  return fetch({
    url: '/usercenter/sys/user/info',
    method: 'GET',
    data: params,
  });
}
//获取用户信息
export function tempPublicKey(params) {
  return fetch({
    url: '/usercenter/temp/public_key',
    method: 'GET',
    data: params,
  });
}
// oss封装上传文件
export function ossUpload(params, type) {
  return oss({
    baseUrl: '/usercenter/resource/file/upload',
    method: 'POST',
    data: params,
    type: type,
  });
}
// 课件上传
export function ossUploadZip(params, type) {
  return oss({
    baseUrl: '/questionlib/generator/uploadFile',
    method: 'POST',
    data: params,
    type: type,
    // host: 'https://api-static-file.niceol.com/renren-fast'
    // host: process.env.NODE_ENV === 'production' ? 'https://api-static-file.niceol.com/renren-fast' : 'http://dev-api-static-file.niceol.com/renren-fast'
  });
}

export function getStsTokenforOss(params) {
  return fetch({
    url: '/questionlib/sts/oss/getStsToken',
    method: 'POST',
    data: params,
  });
}

// 树形图枚举
export function getTree(params) {
  return fetch({
    url: '/usercenter/nice/treefromsingletable/getTree',
    method: 'POST',
    data: params,
  });
}

// 树形图路由
export function manageTree(params) {
  return fetch({
    url: '/usercenter/nice/treefromsingletable/manageTree',
    method: 'POST',
    data: params,
  });
}

// 新的树形图路由
export function getManageTree(params) {
  return fetch({
    url: '/usercenter/operation/niceRouter/manageTree',
    method: 'POST',
    data: params,
  });
}

// <数据库表查询接口>
// 删除某表字段属性
export function deleteField(params) {
  return fetch({
    url: '/usercenter/generator/corefieldanddbproperty/delete',
    method: 'DELETE',
    data: params,
  });
}

// 更新某表字段属性
export function updateField(params) {
  return fetch({
    url: '/usercenter/generator/corefieldanddbproperty/update',
    method: 'PUT',
    data: params,
  });
}

// 已创建表新增属性
export function isCreatedAdd(params) {
  return fetch({
    url: '/usercenter/generator/corefieldanddbproperty/save',
    method: 'POST',
    data: params,
  });
}

//  表集合获取
export function coretable(params) {
  return fetch({
    url: '/usercenter/generator/coretable/list',
    method: 'GET',
    data: params,
  });
}
// 改查看表数据
export function listCoreFieldAndDbPropertyData(params) {
  return fetch({
    url: '/usercenter/generator/coretable/listCoreFieldAndDbPropertyData',
    method: 'GET',
    data: params,
  });
}

// 根据表名 查询表是否存在
export function isExists(params) {
  return fetch({
    url: '/usercenter/core/table/isExists',
    method: 'GET',
    data: params,
  });
}
// db属性信息保存
export function saveTableFieldAndDbProperty(params) {
  return fetch({
    url:
      '/usercenter/generator/corefieldanddbproperty/saveTableFieldAndDbProperty',
    method: 'POST',
    data: params,
  });
}

// 根据表id获取表字段列表
export function listFields(params) {
  return fetch({
    url: '/usercenter/generator/coretableandfield/getFieldsByTableId',
    // url: '/generator/coretableandfield/listFields',
    method: 'GET',
    data: params,
  });
}

// 根据属性组查询 属性详情
export function listGPData(params) {
  return fetch({
    url: '/questionlib/generator/corepropertygroupandproperty/listGPData',
    method: 'GET',
    data: params,
  });
}

// 生成创建表
export function adminCreateTable(params) {
  return fetch({
    url: '/usercenter/core/table/create',
    method: 'GET',
    data: params,
  });
}

// 删除表
export function adminDeleteTable(params) {
  return fetch({
    url: '/usercenter/core/table/delete',
    method: 'GET',
    data: params,
  });
}

// <数据库表查询接口>

// <对应表插入>
// 对应表插入数据
export function tableInsert(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/insert',
    method: 'POST',
    data: params,
  });
}
// 对应表修改数据
export function tableUpdate(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/update',
    method: 'POST',
    data: params,
  });
}
// 删除某表数据
export function tableDeleted(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/deleted',
    method: 'POST',
    data: params,
  });
}
// 列表查询    一次性查询出来的结果集
export function queryList(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/queryList',
    method: 'POST',
    data: params,
  });
}
// 列表查询    一次性查询出来的结果集(改)
export function listByCols(params) {
  return fetch({
    url: '/usercenter/generator/coretable/listByCols?enable=0',
    method: 'GET',
    data: params,
  });
}

// 分页列表查询
export function queryPageList(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/queryAutoSqlPageList',
    // url: '/core/tableRecord/queryPageList',
    method: 'POST',
    data: params,
  });
}

// <对应表插入>
//
// 根据多个字段FieldId获取多个字段所关联的枚举配置
export function findEnumTreeByMultiFieldIds(params) {
  return fetch({
    url: '/usercenter/nice/treefromsingletable/findEnumTreeByMultiFieldIds',
    method: 'POST',
    data: params,
  });
}
// 根据表名查枚举
export function queyEnumByTableName(params) {
  return fetch({
    url: '/usercenter/nice/treefromsingletable/queyEnumByTableName',
    method: 'POST',
    data: params,
  });
}

// 根据多个表名查枚举
export function queyEnumByMultiTableName(params) {
  return fetch({
    url: '/usercenter/nice/treefromsingletable/queyEnumByMultiTableName',
    method: 'POST',
    data: params,
  });
}
// 往表中插入虚拟字段
export function tableandfieldAdd(params) {
  return fetch({
    url: '/questionlib/nice/tableandfield/add',
    method: 'POST',
    data: params,
  });
}

// 根据表名查找表字段
export function listFieldsAndProertiesByTableName(params) {
  return fetch({
    url:
      '/usercenter/generator/corefieldandproperty/listFieldsAndProertiesByTableName',
    method: 'GET',
    data: params,
  });
}

// 根据表名获取表中字段的来源数据
export function getFiledsDataByTableName(params) {
  return fetch({
    url: '/usercenter/generator/inputSource/getFiledsDataByTableName',
    method: 'POST',
    data: params,
  });
}

// 根据表名分页搜索
export function cascadeQuery(params) {
  return fetch({
    url: '/usercenter/core/tableRecord/cascadeQuery',
    method: 'POST',
    data: params,
  });
}

// 根据用黄金类型获取所有相应的人员
export function queryStaffListByType(params) {
  return fetch({
    url: '/questionlib/nice/user/getalluserbyusertype',
    method: 'POST',
    data: params,
  });
}

// 下载模板
export function downloadTemplateFile(params) {
  return fetch({
    // url: '/bussiness/usermangement/downloadTemplateFile',
    url: '/bussiness/userMangement/downloadTemplateFile',
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 导入
export function importData(params, type) {
  return oss({
    baseUrl: '/questionlib/bussiness/userMangement/importData',
    method: 'POST',
    data: params,
    type: type,
  });
}

// 获取niceol路由树
export function niceRouterManageTree(params) {
  return fetch({
    url: '/usercenter/operation/niceRouter/manageTree',
    method: 'POST',
    data: params,
  });
}

// 获取树下表
export function getNodeList(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/getNodeTargetList',
    method: 'POST',
    data: params,
  });
}

// 路由树目标数据添加
export function addTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/addTarget',
    method: 'POST',
    data: params,
  });
}

// 删除树节点目标数据
export function deleteRouterTreeNodeTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/deleteRouterTreeNodeTarget',
    method: 'POST',
    data: params,
  });
}

// 更新树节点目标数据
export function updateRouterTreeNodeTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/updateRouterTreeNodeTarget',
    method: 'POST',
    data: params,
  });
}

// 更新树节点
export function updateRouterTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/updateRouterTreeNode',
    method: 'POST',
    data: params,
  });
}

// 删除树节点
export function deleteRouterTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/deleteRouterTreeNode',
    method: 'POST',
    data: params,
  });
}

// nice移动节点
export function moveRouterTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/routerTree/moveRouterTreeNode',
    method: 'POST',
    data: params,
  });
}

// 权限资源定义列表
export function resourceDefinitionList(params) {
  return fetch({
    url: '/usercenter/operation/permission/resourceDefinitionList',
    method: 'POST',
    data: params,
  });
}

// 角色权限路由具体配置列表
export function routerResourceLinkList(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/routerResourceLinkList',
    method: 'POST',
    data: params,
  });
}

// 角色权限添加或删除（路由资源类型，根据树节点id）
export function addOrDeleteRouterResourceLinkByNodeId(params) {
  return fetch({
    url:
      '/usercenter/operation/roleAndPermission/addOrDeleteRouterResourceLinkByNodeId',
    method: 'POST',
    data: params,
  });
}

// 角色权限批量增加（路由资源类型，根据具体路由）
export function addBatchRouterResourceLink(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/addBatchRouterResourceLink',
    method: 'POST',
    data: params,
  });
}

// 获取按钮树
export function getBtnTree(params) {
  return fetch({
    url: '/usercenter/operation/button/manageTree',
    method: 'POST',
    data: params,
  });
}

// 按钮树节点添加
export function addOrDeleteButtonResourceLinkByNodeId(params) {
  return fetch({
    url:
      '/usercenter/operation/roleAndPermission/addOrDeleteButtonResourceLinkByNodeId',
    method: 'POST',
    data: params,
  });
}

// 获取节点中表数据
export function getNodeTargetList(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/getNodeTargetList',
    method: 'POST',
    data: params,
  });
}

// 角色权限按钮具体配置列表
export function buttonResourceLinkList(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/buttonResourceLinkList',
    method: 'POST',
    data: params,
  });
}

//
// 角色权限批量增加（按钮资源类型，根据具体按钮）
export function addBatchButtonResourceLink(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/addBatchButtonResourceLink',
    method: 'POST',
    data: params,
  });
}

// 更新按钮树节点
export function updateButtonTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/updateButtonTreeNode',
    method: 'POST',
    data: params,
  });
}
// 移动按钮树节点
export function moveButtonTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/moveButtonTreeNode',
    method: 'POST',
    data: params,
  });
}

// 删除按钮树节点
export function deleteButtonTreeNode(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/deleteButtonTreeNode',
    method: 'POST',
    data: params,
  });
}

// 添加按钮树节点
export function buttonTreeAddNode(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/addNode',
    method: 'POST',
    data: params,
  });
}

// 根据按钮树节点id获取表内数据
export function getBtnNodeTargetList(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/getNodeTargetList',
    method: 'POST',
    data: params,
  });
}

// 往按钮选中表中添加数据
export function addBtnTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/addTarget',
    method: 'POST',
    data: params,
  });
}

// 删除按钮节点表内数据
export function deleteButtonTreeNodeTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/deleteButtonTreeNodeTarget',
    method: 'POST',
    data: params,
  });
}

// 更新按钮树节点内表数据
export function updateButtonTreeNodeTarget(params) {
  return fetch({
    url: '/usercenter/operation/system/buttonTree/updateButtonTreeNodeTarget',
    method: 'POST',
    data: params,
  });
}

// 角色权限菜单具体配置列表
export function getMenuResourceLinkList(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/menuResourceLinkList',
    method: 'POST',
    data: params,
  });
}

// 角色菜单权限添加和删除
export function addOrDeleteMenuResourceLink(params) {
  return fetch({
    url: '/usercenter/operation/roleAndPermission/addOrDeleteMenuResourceLink',
    method: 'POST',
    data: params,
  });
}

// 获取当前登录用户拥有的按钮
export function getOwnButton(params) {
  return fetch({
    url: '/usercenter/operation/role/getOwnButton',
    method: 'POST',
    data: params,
  });
}
